// Protocol3 商户渠道配置协议数据 - 渠道进件协议
// 渠道进件流程配置，用于商户接入各支付渠道的标准化进件流程

import { type MerchantChannelConfig3, ProtocolType3, FieldType } from '../types/protocol3-types'

// 微信支付渠道进件配置
const wechatOnboardingConfig: MerchantChannelConfig3 = {
  protocolId: 'PROTOCOL3_WXPAY_ONBOARDING',
  protocolType: ProtocolType3.MERCHANT_CHANNEL_CONFIG_V3,
  channelCode: 'CHANNEL_IF_WXPAY',
  channelName: '微信支付',
  name: '微信支付渠道进件配置',
  version: '3.0.0',
  description: '微信支付渠道商户进件流程配置协议',
  configType: 'CHANNEL_ONBOARDING',
  configSections: [
    {
      sectionKey: 'basic',
      sectionName: '基础信息',
      description: '商户基础信息配置',
      icon: 'UserOutlined',
      order: 1,
      collapsed: false,
      fields: [
        {
          fieldKey: 'merchantName',
          fieldName: '商户名称',
          fieldType: FieldType.INPUT,
          required: true,
          defaultValue: '',
          placeholder: '请输入商户完整名称',
          description: '商户营业执照上的完整名称',
          helpText: '与营业执照名称保持一致',
          validation: {
            maxLength: 64,
            message: '商户名称不能超过64个字符'
          }
        },
        {
          fieldKey: 'merchantShortName',
          fieldName: '商户简称',
          fieldType: FieldType.INPUT,
          required: true,
          defaultValue: '',
          placeholder: '请输入商户简称',
          description: '用于支付凭证显示的商户简称',
          helpText: '不超过20个字符，用户支付时显示',
          validation: {
            maxLength: 20,
            message: '商户简称不能超过20个字符'
          }
        },
        {
          fieldKey: 'businessLicense',
          fieldName: '营业执照号',
          fieldType: FieldType.INPUT,
          required: true,
          defaultValue: '',
          placeholder: '请输入统一社会信用代码',
          description: '营业执照统一社会信用代码',
          helpText: '18位统一社会信用代码',
          validation: {
            pattern: '^[0-9A-HJ-NPQRTUWXY]{2}[0-9]{6}[0-9A-HJ-NPQRTUWXY]{10}$',
            message: '请输入有效的18位统一社会信用代码'
          }
        },
        {
          fieldKey: 'merchantType',
          fieldName: '商户类型',
          fieldType: FieldType.SELECT,
          required: true,
          defaultValue: 'ENTERPRISE',
          options: [
            { label: '企业', value: 'ENTERPRISE' },
            { label: '个体工商户', value: 'INDIVIDUAL_BUSINESS' },
            { label: '政府机关', value: 'GOVERNMENT' },
            { label: '事业单位', value: 'INSTITUTION' },
            { label: '民办非企业', value: 'PRIVATE_NON_ENTERPRISE' }
          ],
          description: '选择商户主体类型'
        },
        {
          fieldKey: 'businessCategory',
          fieldName: '经营类目',
          fieldType: FieldType.SELECT,
          required: true,
          defaultValue: '2001',
          options: [
            { label: '餐饮美食', value: '2001' },
            { label: '生活服务', value: '2002' },
            { label: '零售百货', value: '2003' },
            { label: '教育培训', value: '2004' },
            { label: '医疗健康', value: '2005' },
            { label: '交通出行', value: '2006' },
            { label: '金融理财', value: '2007' },
            { label: '电商平台', value: '2008' },
            { label: '其他', value: '9999' }
          ],
          description: '选择商户经营类目'
        }
      ],
      defaultValues: {
        merchantName: '',
        merchantShortName: '',
        businessLicense: '',
        merchantType: 'ENTERPRISE',
        businessCategory: '2001'
      }
    },
    {
      sectionKey: 'contact',
      sectionName: '联系信息',
      description: '商户联系人信息配置',
      icon: 'ContactsOutlined',
      order: 2,
      collapsed: false,
      fields: [
        {
          fieldKey: 'contactName',
          fieldName: '联系人姓名',
          fieldType: FieldType.INPUT,
          required: true,
          defaultValue: '',
          placeholder: '请输入联系人姓名',
          description: '商户主要联系人姓名',
          helpText: '真实姓名，用于审核联系',
          validation: {
            maxLength: 32,
            message: '联系人姓名不能超过32个字符'
          }
        },
        {
          fieldKey: 'contactPhone',
          fieldName: '联系电话',
          fieldType: FieldType.INPUT,
          required: true,
          defaultValue: '',
          placeholder: '请输入手机号码',
          description: '商户联系人手机号码',
          helpText: '用于接收审核结果和重要通知',
          validation: {
            pattern: '^1[3-9][0-9]{9}$',
            message: '请输入有效的11位手机号码'
          }
        },
        {
          fieldKey: 'contactEmail',
          fieldName: '联系邮箱',
          fieldType: FieldType.INPUT,
          required: true,
          defaultValue: '',
          placeholder: '请输入邮箱地址',
          description: '商户联系邮箱',
          helpText: '用于接收审核结果和账单信息',
          validation: {
            pattern: '^[A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+\\.[A-Za-z]{2,}$',
            message: '请输入有效的邮箱地址'
          }
        },
        {
          fieldKey: 'businessAddress',
          fieldName: '经营地址',
          fieldType: FieldType.TEXTAREA,
          required: true,
          defaultValue: '',
          placeholder: '请输入详细的经营地址',
          description: '商户实际经营场所地址',
          helpText: '详细到门牌号的完整地址',
          uiProps: { rows: 3 },
          validation: {
            maxLength: 200,
            message: '经营地址不能超过200个字符'
          }
        }
      ],
      defaultValues: {
        contactName: '',
        contactPhone: '',
        contactEmail: '',
        businessAddress: ''
      }
    },
    {
      sectionKey: 'settlement',
      sectionName: '结算信息',
      description: '商户资金结算配置',
      icon: 'BankOutlined',
      order: 3,
      collapsed: true,
      fields: [
        {
          fieldKey: 'settlementType',
          fieldName: '结算类型',
          fieldType: FieldType.SELECT,
          required: true,
          defaultValue: 'BANK_CARD',
          options: [
            { label: '银行卡结算', value: 'BANK_CARD' },
            { label: '企业账户', value: 'ENTERPRISE_ACCOUNT' }
          ],
          description: '选择资金结算方式'
        },
        {
          fieldKey: 'bankAccountName',
          fieldName: '开户名称',
          fieldType: FieldType.INPUT,
          required: true,
          defaultValue: '',
          placeholder: '请输入银行开户名称',
          description: '银行账户开户名称',
          helpText: '需与商户名称一致',
          validation: {
            maxLength: 64,
            message: '开户名称不能超过64个字符'
          }
        },
        {
          fieldKey: 'bankAccountNumber',
          fieldName: '银行账号',
          fieldType: FieldType.INPUT,
          required: true,
          defaultValue: '',
          placeholder: '请输入银行账号',
          description: '收款银行账号',
          helpText: '16-20位银行账号',
          validation: {
            pattern: '^[0-9]{16,20}$',
            message: '请输入16-20位数字的银行账号'
          }
        },
        {
          fieldKey: 'bankName',
          fieldName: '开户银行',
          fieldType: FieldType.SELECT,
          required: true,
          defaultValue: '',
          options: [
            { label: '中国工商银行', value: 'ICBC' },
            { label: '中国建设银行', value: 'CCB' },
            { label: '中国农业银行', value: 'ABC' },
            { label: '中国银行', value: 'BOC' },
            { label: '招商银行', value: 'CMB' },
            { label: '交通银行', value: 'BOCOM' },
            { label: '中信银行', value: 'CITIC' },
            { label: '浦发银行', value: 'SPDB' },
            { label: '其他银行', value: 'OTHER' }
          ],
          description: '选择开户银行'
        },
        {
          fieldKey: 'settlementCycle',
          fieldName: '结算周期',
          fieldType: FieldType.SELECT,
          required: true,
          defaultValue: 'T1',
          options: [
            { label: 'T+0（实时结算）', value: 'T0' },
            { label: 'T+1（次日结算）', value: 'T1' },
            { label: 'D+1（次自然日结算）', value: 'D1' },
            { label: '周结算', value: 'WEEKLY' },
            { label: '月结算', value: 'MONTHLY' }
          ],
          description: '选择资金结算周期'
        }
      ],
      defaultValues: {
        settlementType: 'BANK_CARD',
        bankAccountName: '',
        bankAccountNumber: '',
        bankName: '',
        settlementCycle: 'T1'
      }
    },
    {
      sectionKey: 'documents',
      sectionName: '资质文件',
      description: '商户资质证明文件上传',
      icon: 'FileTextOutlined',
      order: 4,
      collapsed: true,
      fields: [
        {
          fieldKey: 'businessLicenseFile',
          fieldName: '营业执照',
          fieldType: FieldType.UPLOAD,
          required: true,
          defaultValue: '',
          placeholder: '上传营业执照图片',
          description: '营业执照扫描件或拍照',
          uiProps: {
            accept: '.jpg,.jpeg,.png,.pdf',
            maxSize: 5 * 1024 * 1024 // 5MB
          },
          validation: {
            message: '请上传营业执照文件（支持JPG、PNG、PDF格式，不超过5MB）'
          }
        },
        {
          fieldKey: 'idCardFile',
          fieldName: '法人身份证',
          fieldType: FieldType.UPLOAD,
          required: true,
          defaultValue: '',
          placeholder: '上传法人身份证',
          description: '法人代表身份证正反面',
          uiProps: {
            accept: '.jpg,.jpeg,.png',
            maxSize: 3 * 1024 * 1024, // 3MB
            multiple: true
          },
          validation: {
            message: '请上传法人身份证正反面（支持JPG、PNG格式，单个文件不超过3MB）'
          }
        },
        {
          fieldKey: 'bankAccountFile',
          fieldName: '银行开户许可证',
          fieldType: FieldType.UPLOAD,
          required: false,
          defaultValue: '',
          placeholder: '上传银行开户许可证',
          description: '银行开户许可证或基本户信息',
          uiProps: {
            accept: '.jpg,.jpeg,.png,.pdf',
            maxSize: 5 * 1024 * 1024 // 5MB
          }
        },
        {
          fieldKey: 'storePhotoFile',
          fieldName: '门店照片',
          fieldType: FieldType.UPLOAD,
          required: false,
          defaultValue: '',
          placeholder: '上传门店照片',
          description: '实体门店照片（如有）',
          uiProps: {
            accept: '.jpg,.jpeg,.png',
            maxSize: 3 * 1024 * 1024, // 3MB
            multiple: true
          }
        }
      ],
      defaultValues: {
        businessLicenseFile: '',
        idCardFile: '',
        bankAccountFile: '',
        storePhotoFile: ''
      }
    }
  ],
  uiConfig: {
    layout: 'vertical',
    labelWidth: 120
  },
  metadata: {
    author: 'AnyPay Team',
    createTime: '2024-01-01',
    updateTime: '2024-01-15',
    tags: ['微信支付', '渠道进件', '商户入驻'],
    category: '渠道进件',
    documentation: '微信支付渠道商户进件配置协议'
  },
  enabled: true
}

// 支付宝渠道进件配置
const alipayOnboardingConfig: MerchantChannelConfig3 = {
  protocolId: 'PROTOCOL3_ALIPAY_ONBOARDING',
  protocolType: ProtocolType3.MERCHANT_CHANNEL_CONFIG_V3,
  channelCode: 'CHANNEL_IF_ALIPAY',
  channelName: '支付宝',
  name: '支付宝渠道进件配置',
  version: '3.0.0',
  description: '支付宝渠道商户进件流程配置协议',
  configType: 'CHANNEL_ONBOARDING',
  configSections: [
    {
      sectionKey: 'basic',
      sectionName: '基础信息',
      description: '商户基础信息配置',
      icon: 'UserOutlined',
      order: 1,
      collapsed: false,
      fields: [
        {
          fieldKey: 'merchantName',
          fieldName: '商户名称',
          fieldType: FieldType.INPUT,
          required: true,
          defaultValue: '',
          placeholder: '请输入商户完整名称',
          description: '与营业执照一致的商户名称',
          validation: {
            maxLength: 64,
            message: '商户名称不能超过64个字符'
          }
        },
        {
          fieldKey: 'aliasName',
          fieldName: '商户别名',
          fieldType: FieldType.INPUT,
          required: true,
          defaultValue: '',
          placeholder: '请输入商户别名',
          description: '支付宝收银台显示名称',
          helpText: '用户支付时看到的商户名称',
          validation: {
            maxLength: 32,
            message: '商户别名不能超过32个字符'
          }
        },
        {
          fieldKey: 'businessLicense',
          fieldName: '统一社会信用代码',
          fieldType: FieldType.INPUT,
          required: true,
          defaultValue: '',
          placeholder: '请输入18位统一社会信用代码',
          description: '营业执照上的统一社会信用代码',
          validation: {
            pattern: '^[0-9A-HJ-NPQRTUWXY]{18}$',
            message: '请输入有效的18位统一社会信用代码'
          }
        },
        {
          fieldKey: 'businessScope',
          fieldName: '经营范围',
          fieldType: FieldType.TEXTAREA,
          required: true,
          defaultValue: '',
          placeholder: '请输入经营范围',
          description: '营业执照上的经营范围',
          uiProps: { rows: 4 },
          validation: {
            maxLength: 500,
            message: '经营范围不能超过500个字符'
          }
        },
        {
          fieldKey: 'mccCode',
          fieldName: 'MCC码',
          fieldType: FieldType.SELECT,
          required: true,
          defaultValue: '5812',
          options: [
            { label: '5812 - 餐饮服务', value: '5812' },
            { label: '5411 - 超市', value: '5411' },
            { label: '5814 - 快餐店', value: '5814' },
            { label: '5999 - 其他零售', value: '5999' },
            { label: '8299 - 其他服务', value: '8299' },
            { label: '7372 - 软件开发', value: '7372' },
            { label: '8220 - 高等教育', value: '8220' }
          ],
          description: '商户类别码（MCC）'
        }
      ],
      defaultValues: {
        merchantName: '',
        aliasName: '',
        businessLicense: '',
        businessScope: '',
        mccCode: '5812'
      }
    },
    {
      sectionKey: 'contact',
      sectionName: '联系信息',
      description: '商户联系人信息',
      icon: 'ContactsOutlined',
      order: 2,
      collapsed: false,
      fields: [
        {
          fieldKey: 'legalPersonName',
          fieldName: '法人代表',
          fieldType: FieldType.INPUT,
          required: true,
          defaultValue: '',
          placeholder: '请输入法人代表姓名',
          description: '营业执照上的法人代表姓名',
          validation: {
            maxLength: 32,
            message: '法人代表姓名不能超过32个字符'
          }
        },
        {
          fieldKey: 'legalPersonIdCard',
          fieldName: '法人身份证号',
          fieldType: FieldType.INPUT,
          required: true,
          defaultValue: '',
          placeholder: '请输入18位身份证号',
          description: '法人代表身份证号码',
          validation: {
            pattern: '^[1-9][0-9]{5}(18|19|20)[0-9]{2}((0[1-9])|(1[0-2]))(([0-2][1-9])|10|20|30|31)[0-9]{3}[0-9Xx]$',
            message: '请输入有效的18位身份证号码'
          }
        },
        {
          fieldKey: 'contactPhone',
          fieldName: '联系电话',
          fieldType: FieldType.INPUT,
          required: true,
          defaultValue: '',
          placeholder: '请输入手机号码',
          description: '商户联系电话',
          validation: {
            pattern: '^1[3-9][0-9]{9}$',
            message: '请输入有效的11位手机号码'
          }
        },
        {
          fieldKey: 'contactEmail',
          fieldName: '联系邮箱',
          fieldType: FieldType.INPUT,
          required: true,
          defaultValue: '',
          placeholder: '请输入邮箱地址',
          description: '商户联系邮箱',
          validation: {
            pattern: '^[A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+\\.[A-Za-z]{2,}$',
            message: '请输入有效的邮箱地址'
          }
        }
      ],
      defaultValues: {
        legalPersonName: '',
        legalPersonIdCard: '',
        contactPhone: '',
        contactEmail: ''
      }
    },
    {
      sectionKey: 'settlement',
      sectionName: '结算信息',
      description: '资金结算配置',
      icon: 'BankOutlined',
      order: 3,
      collapsed: true,
      fields: [
        {
          fieldKey: 'bankAccountType',
          fieldName: '账户类型',
          fieldType: FieldType.SELECT,
          required: true,
          defaultValue: 'ENTERPRISE',
          options: [
            { label: '对公账户', value: 'ENTERPRISE' },
            { label: '对私账户', value: 'PERSONAL' }
          ],
          description: '选择结算账户类型'
        },
        {
          fieldKey: 'bankAccountName',
          fieldName: '开户名',
          fieldType: FieldType.INPUT,
          required: true,
          defaultValue: '',
          placeholder: '请输入开户名',
          description: '银行账户开户名',
          validation: {
            maxLength: 64,
            message: '开户名不能超过64个字符'
          }
        },
        {
          fieldKey: 'bankAccountNumber',
          fieldName: '银行账号',
          fieldType: FieldType.INPUT,
          required: true,
          defaultValue: '',
          placeholder: '请输入银行账号',
          description: '收款银行账号',
          validation: {
            pattern: '^[0-9]{16,20}$',
            message: '请输入16-20位数字的银行账号'
          }
        },
        {
          fieldKey: 'bankCode',
          fieldName: '开户银行',
          fieldType: FieldType.SELECT,
          required: true,
          defaultValue: '',
          options: [
            { label: '工商银行', value: 'ICBC' },
            { label: '建设银行', value: 'CCB' },
            { label: '农业银行', value: 'ABC' },
            { label: '中国银行', value: 'BOC' },
            { label: '招商银行', value: 'CMB' },
            { label: '交通银行', value: 'BOCOM' }
          ],
          description: '选择开户银行'
        }
      ],
      defaultValues: {
        bankAccountType: 'ENTERPRISE',
        bankAccountName: '',
        bankAccountNumber: '',
        bankCode: ''
      }
    }
  ],
  uiConfig: {
    layout: 'vertical',
    labelWidth: 120
  },
  metadata: {
    author: 'AnyPay Team',
    createTime: '2024-01-01',
    updateTime: '2024-01-15',
    tags: ['支付宝', '渠道进件', '商户入驻'],
    category: '渠道进件',
    documentation: '支付宝渠道商户进件配置协议'
  },
  enabled: true
}

// 导出渠道进件配置协议数据数组
export const protocol3OnboardingConfigs: MerchantChannelConfig3[] = [
  wechatOnboardingConfig,
  alipayOnboardingConfig
]